package day1104.demo06;

import java.util.ArrayList;

/**
 * @author wql
 * @version 1.0
 * @date 2022/11/4 17:30
 */

public class Test {
    public static void main(String[] args) {
        ArrayList<Wql> list = new ArrayList<>();
        list.add(new Wql("老一",18));
        list.add(new Wql("老八",20));

        list.stream().filter(item->{
            return item.getAge()>18;
        }).forEach(item-> System.out.println(item));

        list.stream().filter(item->item.getName().equals("老一")).forEach(item-> System.out.println(item));

        long count = list.stream().filter(item -> {
            return item.getAge() == 20;
        }).count();
        System.out.println("count = " + count);
    }
}
class Wql{
    private  String name;
    private Integer age;

    public Wql(String name, Integer age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Wql{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
